var app = getApp();
Page({
  data: {
    'text': '',
    oNumber: '',
    oRefundsreason: ''
  },
  changeInputValue(ev) {
    this.setData({
      oRefundsreason: ev.detail.value,
    })
  },

  //申请退货
    refund: function (e) {
    var that = this;
    var oNumber = e.currentTarget.dataset.onumber;
    console.log("oNumber1111" + oNumber);
    //判断输入框为空
    var input = that.data.oRefundsreason; // 获取评论内容
    if (input.length > 5 && input.length < 80) {
      wx.request({
        url: 'https://www.brvpmusic.com/api/orderProduct/refund',
        // url: 'http://2624519ed2.qicp.vip/api/orderProduct/refund',
        method: 'GET',
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        data: {
          oNumber: oNumber,
          // openid: wx.getStorageSync('OpenId'),
          oRefundsreason: that.data.oRefundsreason,
          score: that.data.star
        },
        success: function (res) {
          console.log(res.data);
          console.log('退货成功');
          wx.showToast({
            title: '退货成功',
          });
            setTimeout(() => {
              console.log('退货成功222');
                wx.navigateBack()
            }, 1000);
        }
      })
    } else {
      if (input.length > 80) {
        wx.showToast({
          title: '退款原因字数超出限制!',
          icon: 'none',
          duration: 2000
        });
      } else {
        wx.showToast({
          title: '退款原因字数不够!',
          icon: 'none',
          duration: 2000
        });
      }
      return false;
    }
  },
  onShow: function (e) {
  },

  onLoad: function (e) {
    console.log("onumber---" + e.onumber);
    this.setData({
      oNumber: e.onumber,
    })
  }
})